from dataclasses import dataclass
from typing import Optional

@dataclass
class TokenVerifyRequest:
    """Token验证请求"""
    token: str  # 令牌
    Sessionid: str  # 会话ID

@dataclass
class TokenVerifyData:
    """Token验证响应数据"""
    result: bool  # 验证结果
    msg: str  # 消息
    
    @classmethod
    def from_dict(cls, data: dict):
        """从字典创建数据对象"""
        return cls(
            result=data.get('result', False),
            msg=data.get('msg', '')
        )

@dataclass
class TokenVerifyResponse:
    """Token验证响应"""
    code: int  # 状态码
    msg: str  # 消息
    timestamp: str  # 时间戳
    data: Optional[TokenVerifyData]  # 数据
    
    @classmethod
    def from_dict(cls, data: dict):
        """从字典创建响应对象"""
        response_data = None
        if data.get('data'):
            response_data = TokenVerifyData.from_dict(data.get('data'))
        
        return cls(
            code=data.get('code'),
            msg=data.get('msg'),
            timestamp=data.get('timestamp'),
            data=response_data
        )
